<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #big{
            position: relative;
        }
        button{
            user-select: none;
        }
        .active{
            width: 80px;
            height: 100px;
            background-color: #888888;
        }
        .card{
            position:absolute;
            top: 100px;
            left: 0px; 
            width: 300px;
            height: 300px;
            background-color: cyan;
            border: 1px solid black;
            display: none;
        }
        #big .card1{
            display: block;
        }
    </style>
</head>
<body>
    <div id="big">
        <button class="active">按钮一</button>
        <button class="list">按钮二</button>
        <button>按钮三</button>
        <button>按钮四</button>
        <div>
            <div class="card card1">体育</div>
            <div class="card">数学</div>
            <div class="card">英语</div>
            <div class="card">化学</div>
         
        </div>
    </div>

    <script>
        // 获取按钮集合
        var btn = document.getElementsByTagName('button')
        // 获取类名为card的四个div
        var  $div = document.getElementsByClassName('card')
        // 循环给按钮加点击事件
        for(var i = 0;i < btn.length;i++){
            // 记录索引并设置为i
            btn[i].idx = i
            // 逐个绑定点击事件
            btn[i].onclick = function(){
            //    循环排他
                for(var j = 0;j < btn.length;j++){
                    // 清空按钮类名
                    // 把所有卡片影藏
                    btn[j].className = '';
                    $div[j].style.display = 'none'
                }
                // 给指向性点击按钮设置类名
                this.className = 'active';
                // 给与点击按钮索引对应的卡片设置block点击时出现
                $div[this.idx].style.display = 'block';
            }
           
        }
 
    </script>
</body>
</html>